<?php
/**
 * Created by PhpStorm.
 * User: 老王
 * Date: 2016/11/2
 * Time: 13:21
 */
namespace app\home\controller;
use app\home\model\WechatDepartment;
use app\home\model\WechatUser;
use think\Db;

class Structure extends Base{
    /*
     * 组织架构主页
     */
    public function index(){
        // 组织介绍
        $info = Db::name('show')->find();
        $this->assign('info',$info);
        // 组织架构
        $deps = Db::name('wechat_department')->where(['id' => ['neq',2],'status'=>['eq',1]])->select();
        $this->assign('deps',$deps);
        return $this->fetch();
    }
    /*
     * 组织架构详情页
     */
    public function detail(){
        $this->checkAnonymous();
        $id = input('id/d');
        $list = WechatUser::where(['department' => $id,'party' => 1,'state'=>1])->field('name,position,gender,headimgurl')->select();
        $lists = WechatUser::where(['department' => $id,'party' => 0,'state'=>1])->field('name,position,gender,headimgurl')->select();
        $this->assign('list',$list);
        $this->assign('lists',$lists);
        return $this->fetch();
    }
}
